// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (c) 2023 Yevhen Babiichuk (DustDFG)

#ifndef _VIEW_TUBE_HPP_
#define _VIEW_TUBE_HPP_

#include <cstdint>
#include <vector>

#include <SFML/Graphics.hpp>
#include <SFML/Graphics/Drawable.hpp>

#include <Abracadabra/View/Theme.hpp>
#include <DotSort/View/ISFMLTube.hpp>

namespace View
{

class Tube : public ISFMLTube, public sf::Drawable
{
	private:
		std::vector<sf::RectangleShape> slots;

		Theme* theme;

		void fillSlot(uint8_t slotIndex, sf::Texture* texture, sf::IntRect textureRect) override;

		void fillSlotDot(uint8_t slotIndex, std::optional<uint8_t> dot) override;
		void fillSlotTubePart(uint8_t slotIndex, uint8_t partIndex) override;
		void fillSlotSelectedTubePart(uint8_t slotIndex, uint8_t partIndex) override;

	protected:
		virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override;

	public:
		Tube(uint8_t size, sf::FloatRect boundsRect, Theme* theme);

		sf::RectangleShape& operator[](uint8_t index)
		{
			return this->slots[index];
		}
};

}

#endif
